package com.yh.homestay.security;

import com.yh.homestay.pojo.UserStaff;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.List;

/**
 * @ClassName SecurityUserStaff
 * @Description TODO
 * @Author GCL
 * @Date 2020/1/6 18:02
 */
public class SecurityUserStaff extends UserStaff implements UserDetails {
    private String password;
    private String username;
    List<GrantedAuthority> authorities;

    public SecurityUserStaff(String username,String password ,List<GrantedAuthority> authorities){
       this.password=password;
       this.username=username;
       this.authorities=authorities;
    }

    @Override//获取数据库存储的密码
    public String getPassword() {
        return password;
    }

    @Override//获取数据库存储的用户
    public String getUsername() {
        return username;
    }

    @Override//获取数据库中存储的用户role
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return this.authorities;
    }

    @Override//账号过期验证
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override//账号是否被锁定
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override//证书（密码）过期验证
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override//账号有效验证
    public boolean isEnabled() {
        return true;
    }
}
